package com.leanin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.leanin.domain.CallBackConfig;
import com.leanin.response.DataOutResponse;
import com.leanin.service.CallBackConfigService;

@RestController
@RequestMapping("config")
public class CallBackConfigController {

	@Autowired
	private CallBackConfigService callBackConfigService;
	
	@GetMapping("findConfigList")
	public DataOutResponse findConfigList(@RequestParam int page,@RequestParam int pageSize,@RequestParam(required=false) Integer callBackType) {
		return callBackConfigService.findConfigList(page,pageSize,callBackType);
	}
	
	@GetMapping("findConfigById")
	public DataOutResponse findConfigById(@RequestParam String configNum) {
		return callBackConfigService.findConfigById(configNum);
	}
	
	@GetMapping("updateConfigStatus")
	public DataOutResponse updateConfigStatus(@RequestParam String configNum,@RequestParam int status) {
		return callBackConfigService.updateConfigStatus(configNum, status);
	}
	
	@PostMapping("addConfig")
	public DataOutResponse addConfig(@RequestBody CallBackConfig record) {
		return callBackConfigService.addConfig(record);
	}
	
	@PostMapping("updateConfig")
	public DataOutResponse updateConfig(@RequestBody CallBackConfig record) {
		return callBackConfigService.updateConfig(record);
	}
}
